﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using FileSystem.Services.IServices;
using FileSystem.Services.Realization;
using Moq;

namespace FileSystem.UnitTest.Helpers {
    /// <summary>
    /// 磁盘块存储帮助类
    /// </summary>
    public class DiskBlockStorageHelper {
        /// <summary>
        /// 获得已初始化的磁盘块存储
        /// </summary>
        public static async Task<DiskBlockStorage>
            GetInitializedDiskBlockStorageAsync() {
            var diskBlockStorage = new DiskBlockStorage(
                new Mock<IPreferenceStorage>().Object);
            await diskBlockStorage.InitializeAsync();
            return diskBlockStorage;
        }

        /// <summary>
        /// 删除磁盘块信息数据库文件
        /// </summary>
        public static async Task RemoveDatabaseFile() {
            var diskBlockStorage = new DiskBlockStorage(null);
            await diskBlockStorage.CloseAsync();
            File.Delete(DiskBlockStorage.DbPath);
        }
    }
}